<?php
namespace app\api\model;

use app\model\Base;

class MerchantLog extends Base
{
    public function getTypeFormatAttr($value, $data)
    {
        $str = "股东" . Base::$goldName;
        switch ($data['type']){
            case 1:
                $str = "公司" . Base::$goldName;
                break;
            case 2:
                $str = "股东" . Base::$goldName;
                break;
        }
        return $str;
    }

    public function getContentAttr($value, $data)
    {
        $str = "来自：店铺消费积分";
//        switch ($data['type']){
//            case 1:
//                $str = "来自：店铺消费积分";
//                break;
//            case 2:
//                $str = "来自：店铺消费积分";
//                break;
//        }
        return $str;
    }

    public static function induce($merchantId, $amount, $type = 1)
    {
        //$type 1股东 2公司
        /**
         * TODO
         * $type 判断是否需要手续费
         * 手续费比例后台配置，直接获取后台手续费比例
         * 加手续费字段，扣除手续费逻辑
         */
        $add = [];
        $add['merchant_id'] = $merchantId;
        $add['amount'] = $amount;
        $add['type'] = $type;

        self::create($add);
        return true;
    }
}